<?php
include_once 'utiles.php';

if(login_check() == true) {
?>
  <script type="text/JavaScript" src="js/sha512.js"></script>
  <script type="text/JavaScript" src="js/forms.js"></script>
  <form style="width:500px" class="form-signin" role="form" action="changePass.php" method = "post" name="changePassForm">
	<input type="password" class="form-control" name="oldPass" placeholder="Contraseña anterior" required="" autofocus="">
	<input type="password" class="form-control" name="newPass" placeholder="Contraseña nueva" required="">
	<input type="password" class="form-control" name="newPass2" placeholder="Reitere la contraseña nueva" required="">
	<button class="btn btn-lg btn-primary btn-block" type="button" onclick="change_pass(this.form, this.form.oldPass,this.form.newPass,this.form.newPass2);">Cambiar</button>
		<?php
			if (isset($_GET['error'])) {
				$key = !empty($_GET['error']) ? $_GET['error'] : 'default';
				$msgs = ['1' => 'No se pudo modificar su contraseña. Intentelo nuevamente.',
						'default' => ''];

				echo '<p>' . $msgs[$key] . '</p>';
			}
		?>
  </form>  
<?php
} else {
	header('Location: login.php?error=2');
}
?>